<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="0;url=qiangda.jsp">
<title>Insert title here</title>
<script type="text/javascript">
var xmlHttp = false;
function doIt(){
    sendRequest("GET","ajax.action",true,callback);
}
function sendRequest(method, url, async, callback) {
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        //xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        var msxmls = ["MSXML3" , "MSXML2" , "Microsoft"];
        for(var i=0; i < msxmls.length; i++)
        {
        	try
        	{
        		xmlHttp = new ActiveXObject(msxmls[i]+".XMLHTTP");
        	}
        	catch(e)
        	{
        		//alert("您的浏览器不支持XMLHTTP控件");
        	}
        }
    }
    if (!xmlHttp) {
        alert("当前浏览器无法创建XMLHttpRequest对象");
    } else {
        //初始化XMLHttpRequest对象
        xmlHttp.open(method, url, async);
        //定义一个回调函数
        xmlHttp.onreadystatechange = callback;
        //发送
        xmlHttp.send();
    }
}
function callback(){
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        var str = xmlHttp.responseText;
        //alert(str);
        var obj = eval("(" + str + ")");
        //text.innerText=object.name;
        //prompt(12);
        document.getElementById("text").innerHTML = obj.name + " : " + obj.age;
        //alert(obj.name + " : " + obj.age);
    }
}
</script>
</head>
<body>
<!--     <button id="b" onclick="doIt()">获得JSON对象</button>
    <br/>
    <font color="red">
    <span id="text"></span>
    </font> -->
</body>
</html>